home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
win
/
pascal
/
fcsrc.exe
/
FILECLRK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-06-04
|
8KB
|
300 lines
program FILECLRK;
{$R fc}
{$D Copyright (c) 1992 by David A. Peoples}
{$D Version 1.0}
uses WObjects, WinTypes, WinProcs, WinDOS, Strings, FCINI, FCDLGS;
{$I fc.inc}
const
id_FCDlgWindow = 100;
id_FCAppLabel = 101;
id_FCDirLabel = 102;
id_FCFilterEdit = 103;
id_FCFileList = 104;
id_FCIcon = 200;
cm_Select = 101;
cm_Edit = 102;
cm_Quit = 103;
cm_HelpIndex = 110;
cm_HelpTutorial = 111;
cm_HelpAbout = 112;
id_AboutDlg = 200;
type
PFCDlg = ^FCDlg;
FCDlg = object(TDlgWindow)
PTranRec: PTransferRec;
FCHelpFile: array[0..fsPathName] of Char;
Choice: array[0..fsPathName] of Char;
SectionName: array[0..PrgManItm] of Char;
FCAppLabel: PStatic;
FCDirLabel: PStatic;
FCFilterEdit: PEdit;
FCFileList: PListBox;
constructor Init(AParent: PWindowsObject;
AName: PChar);
destructor Done; virtual;
procedure SetupWindow; virtual;
function GetClassName: PChar; virtual;
procedure GetWindowClass(var AWndClass: TWndClass); virtual;
procedure Update;
procedure clickFCFileList(var Msg: TMessage);
virtual id_first + id_FCFileList;
procedure Ok(var Msg: TMessage);
virtual id_First + id_Ok;
procedure Launch;
procedure CMSelect(var Msg: TMessage);
virtual cm_First + cm_Select;
procedure CMEdit(var Msg: TMessage);
virtual cm_First + cm_Edit;
procedure CMQuit(var Msg: TMessage);
virtual cm_First + cm_Quit;
procedure CMHelpIndex(var Msg: TMessage);
virtual cm_First + cm_HelpIndex;
procedure CMHelpTutorial(var Msg: TMessage);
virtual cm_First + cm_HelpTutorial;
procedure CMHelpAbout(var Msg: TMessage);
virtual cm_First + cm_HelpAbout;
end;
FCApplication = object(TApplication)
procedure InitMainWindow; virtual;
end;
{ ---- FCApplication methods -------------------------------------- }
procedure FCApplication.InitMainWindow;
begin
MainWindow := New(PFCDlg, Init(nil, PChar(id_FCDlgWindow)));
end;
{ ---- FCDlg methods ----------------------------------------------- }
constructor FCDlg.Init(AParent: PWindowsObject; AName: PChar);
var
AControl: PControl;
begin
TDlgWindow.Init(AParent, AName);
FCAppLabel := New(PStatic, InitResource(@Self, id_FCAppLabel,
fsPathName+1));
FCDirLabel := New(PStatic, InitResource(@Self, id_FCDirLabel,
fsPathName+1));
FCFilterEdit := New(PEdit, InitResource(@Self, id_FCFilterEdit,
fsFileName+fsExtension+1));
FCFileList := New(PListBox, InitResource(@Self, id_FCFileList));
PTranRec := New(PTransferRec);
FillChar(PTranRec^, Sizeof(PTranRec^), #0);
end;
destructor FCDlg.Done;
begin
WinHelp(HWindow, FCHElpFile, HELP_QUIT, LongInt(NIL));
TDlgWindow.Done;
end;
function FCDlg.GetClassName: PChar;
begin
GetClassName := PChar(AppName);
end;
procedure FCDlg.GetWindowClass(var AWndClass: TWndClass);
begin
TDlgWindow.GetWindowClass(AWndClass);
AWndClass.HIcon := LoadIcon(HInstance, PChar(id_FCIcon));
end;
procedure FCDlg.SetupWindow;
var
Buffer: array[0..fsPathName] of Char;
Temp1: array[0..fsFileName] of Char;
Temp2: array[0..fsExtension] of Char;
begin
TDlgWindow.SetupWindow;
StrPCopy(Buffer, ParamStr(0));
FileSplit(Buffer, FCHelpFile, Temp1, Temp2);
if FCHelpFile[3] = #0 then FCHelpFile[2] := #0;
StrCat(FCHelpFile, '\');
StrCat(FCHelpFile, HelpName);
if ParamCount > 0 then
begin
StrPCopy(Buffer, ParamStr(1));
StrLCopy(SectionName, Buffer, Sizeof(SectionName)-1);
end
else
StrCopy(SectionName, '_DEFAULT');
GetIniData(PTranRec, SectionName);
Update;
end;
procedure FCDlg.Update;
var
Title: array[0..MTitleLen] of Char;
ShortApp, Scratch: array[0..fsPathName] of Char;
P: PChar;
L: Integer;
begin
StrCopy(Scratch, SectionName);
if StrLen(Scratch) > MTitleLen-16 then
begin
Scratch[MTitleLen-19] := #0;
StrCat(Scratch, '...');
end;
StrCopy(Title, 'File Clerk - [');
StrCat(Title, Scratch);
StrCat(Title, ']');
SetWindowText(HWindow, Title);
FCFilterEdit^.SetText(StrLower(PTranRec^.EFltr));
StrCopy(ShortApp, StrLower(PTranRec^.EApp));
if StrLen(ShortApp) > 30 then
begin
StrCopy(Scratch, PTranRec^.EApp);
repeat
Scratch[0] := ' ';
P := StrScan(Scratch, '\');
L := StrLen(P);
StrMove(Scratch, P, L+1);
until L < 25;
StrLCopy(ShortApp, PTranRec^.EApp, 3);
StrCat(ShortApp, '...');
StrCat(ShortApp, Scratch);
end;
FCAppLabel^.SetText(ShortApp);
FCDirLabel^.SetText(StrLower(PTranRec^.EDir));
StrCopy(Choice, PTranRec^.EDir);
if Choice[3] = #0 then Choice[2] := #0;
StrCat(Choice, '\');
StrCat(Choice, PTranRec^.EFltr);
DlgDirList(HWindow, Choice, id_FCFileList, id_FCDirLabel, $4010);
end;
procedure FCDlg.clickFCFileList(var Msg: TMessage);
begin
if Msg.LParamHi = lbn_DblClk then
FCDlg.Ok(Msg);
end;
procedure FCDlg.Launch;
var
ACommandLine: array[0..144] of Char;
OldCursor: HCursor;
State: Word;
begin
OldCursor := SetCursor(LoadCursor(0, idc_Wait));
if PTranRec^.RFull = bf_Checked then State := sw_ShowMaximized;
if PTranRec^.RWin = bf_Checked then State := sw_ShowNormal;
if PTranRec^.RMin = bf_Checked then State := sw_ShowMinimized;
if PTranRec^.CNeedsApp = bf_UnChecked then
begin
StrCat(Choice, ' ');
StrCat(Choice, PTranRec^.EPrm);
WinExec(Choice, State);
end
else
begin
StrCopy(ACommandLine, PTranRec^.EApp);
StrCat(ACommandLine, ' ');
StrCat(ACommandLine, PTranRec^.EPrm);
StrCat(ACommandLine, ' ');
StrCat(ACommandLine, Choice);
WinExec(ACommandLine, State);
end;
SetCursor(OldCursor);
end;
procedure FCDlg.Ok(var Msg: TMessage);
var
Answer: Integer;
IsDir: Boolean;
begin
if FCFilterEdit^.IsModified = true then
begin
FCFilterEdit^.GetText(PTranRec^.EFltr, fsFileName+fsExtension);
FileExpand(Choice, PTranRec^.EFltr);
Update;
FCFilterEdit^.ClearModify
end else
if SendDlgItemMessage(HWindow, id_FCFileList, lb_GetCurSel,
0, 0) <> lb_Err then
begin
IsDir := DlgDirSelect(HWindow, Choice,
id_FCFileList);
FileExpand(Choice, Choice);
if IsDir = true then
begin
FCFilterEdit^.GetText(PTranRec^.EFltr, fsFileName+fsExtension);
StrCat(Choice, PTranRec^.EFltr);
DlgDirList(HWindow, Choice, id_FCFileList, id_FCDirLabel, $4010);
end
else
begin
Launch;
Cancel(Msg);
end;
end;
end;
procedure FCDlg.CMSelect(var Msg: TMessage);
var
PD: PDialog;
begin
PD := New(PSctnDlg, Init(@Self, SectionName, Sizeof(SectionName)-1));
if Application^.ExecDialog(PD) = id_Ok then
begin
GetIniData(PTranRec, SectionName);
Update;
end;
end;
procedure FCDlg.CMEdit(var Msg: TMessage);
var
PD: PDialog;
begin
PD := New(PFCSDlg, Init(@Self, SectionName));
PD^.TransferBuffer := PTranRec;
if Application^.ExecDialog(PD) = id_Ok then Update;
end;
procedure FCDlg.CMQuit(var Msg: TMessage);
begin
FCDlg.Done;
end;
procedure FCDlg.CMHelpIndex(var Msg: TMessage);
begin
WinHelp(HWindow, FCHelpFile, HELP_INDEX, LongInt(NIL));
end;
procedure FCDlg.CMHelpTutorial(var Msg: TMessage);
begin
WinHelp(HWindow, FCHelpFile, HELP_CONTEXT, LongInt(TutorialHelp));
end;
procedure FCDlg.CMHelpAbout(var Msg: TMessage);
var
Dialog: TDialog;
begin
Dialog.Init(@Self, PChar(id_AboutDlg));
Dialog.Execute;
Dialog.Done
end;
{ Main application loop }
var
FCApp: FCApplication;
begin
FCApp.Init('FC');
FCApp.Run;
FCApp.Done
end.